<?php

/**
 * Ce fichier contient la classe Form_Diplome
 *
 * @copyright  2012 UVT Oussama Limam
 * @license    "New" GPL3
*/

/**
 *  une entrée Inscription.
 *
 * @copyright  2012 UVT Oussama Limam
 * @license    "New" GPL3
 */
class Application_Form_Diplome  extends Twitter_Bootstrap_Form_Horizontal
{
         
	
	
    public function init()
    {
    	$this->setMethod("post");

    	$decorator=array(
    			array('ViewHelper', array('tag'   => 'div', "class"=>"controls")),
    			array('Label' , array(  "class"=>"control-label")),
    			'Errors',
    			new Zend_Form_Decorator_HtmlTag(array(
    					'tag'   => 'div', "class"=>"control-group"
    			))
    	);
    	
    	$translate = Zend_Registry::get('Zend_Translate');
    	$translate->setLocale('fr');
    	 
    	$diplome= new Zend_Form_Element_Text('diplome');
    	
    	 
    	$diplome->setLabel('Diplome ')
    	->setRequired(true); 
    	 
    	
    	$anneedeplome= new Zend_Form_Element_select('anneediplome');
    	 
    	$anneedeplome->addMultiOption( "","");
    	$anneedeplome->setLabel("Annee d'obtention ")
    	->setRequired(true);
    	for($i=1978;$i<=date("Y");$i++){
    		$date= $i.'-'.($i+1);
    		$anneedeplome->addMultiOption("$date","$date");
    	}
    	 
    	$session= new Zend_Form_Element_select('sessiondiplome');
    	
    	$session->addMultiOption("","");
    	$session->setLabel("Session ")
    	->setRequired(true);;
    	$session->addMultiOption("P","Principale");
    	$session->addMultiOption("R","Rattrappage");
    	 
    	$pays= new Zend_Form_Element_select('paysdiplome');
    	 
    	$pays->addMultiOption("","");
    	$pays->setLabel("Pays ")
    	->setRequired(true);
    	$pays->addMultiOption("TN","Tunise");
    	$pays->addMultiOption("FR","France");
    	 
    	$moyenne = new Zend_Form_Element_Text('moyennediplome');
    	$moyenne->setRequired(true)
    	->addValidators(array(new Zend_Validate_Float('en_US')))
    	->setAttrib("class", "input-large");
    	$moyenne->setLabel($translate->_('moyenne').'* : ');
    	
    	
    	
    	$universite = new Zend_Form_Element_Text('universite');
    	$universite->setRequired(true) 
    	->setAttrib("class", "input-large");
    	$universite->setLabel($translate->_('Université-Ecole').'* : ');
    	 
    	
    	
    	$relever = new Zend_Form_Element_File('relever');
    	$relever->setLabel('Relever:')
    	->setDestination(APPLICATION_PATH .'/modules/admin/upload');
    	 
    	$this->setAttrib('relever', 'multipart/form-data');
    	
    	  
    	$sendBt = new Zend_Form_Element_Submit('enregistrerdiplome');
    	$sendBt->setLabel('Enregistrer');
    	$sendBt->setAttrib('class', 'btn btn-primary');
    	
    	$annuler = new Zend_Form_Element_Button('Annulerdiplome');
    	$annuler->setLabel('Annuler');
    	$annuler->setAttrib('class', 'btn btn-danger');
    	
    	
    	$diplome->setDecorators($decorator);
    	$moyenne->setDecorators($decorator);
    	$session->setDecorators($decorator);
    	$pays->setDecorators($decorator);
    	$anneedeplome->setDecorators($decorator);
    	$universite->setDecorators($decorator);
    	$sendBt->setDecorators(array('ViewHelper'));
    	$annuler->setDecorators(array('ViewHelper'));
    	
    	$this->addElement($relever, 'relever');
    	$this->addElements(array($universite,$moyenne,$diplome,$session,$pays,$anneedeplome,$sendBt,$annuler));
    	
    	 
    	
    }
   
}